//
//  AppDelegate.m
//  OCStarterProject
//
//  Created by huaya on 2025/10/2.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import "AppDelegate+Facebook.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [TL_ViewHelper setStateBarLightStyle];
    
    // 配置 MJRefresh 默认使用英文
    [MJRefreshConfig defaultConfig].languageCode = @"en"; // 将语言代码设置为英文
    
    // 初始化Facebook SDK
    [self initFacebookWithApplication:application launchOptions:launchOptions];
    
    // 创建并设置 window
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    // 设置根视图控制器
    self.window.rootViewController = [TabBarCtrlUtils sharedManager].rootTabbarController;
    
    // 显示 window
    [self.window makeKeyAndVisible];
    
    
    [[MKApplePayUtils sharedInstance] restorePurchases];
    
    return YES;
}

- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    return YES;
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {

    if ([[GIDSignIn sharedInstance] handleURL:url]) {
        return YES;
    }

    if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]]) {
        return YES;
    }

    return YES;
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    
    [[MKApplePayUtils sharedInstance] restorePurchases];
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
    
    return YES;
}
@end
